/**
 * Created by LXH on 2017/11/1.
 */
import axios from './axios.js'
import store from '../vuex/'
import qs from 'qs'

export const commonService = {
    api: {},
    /* 个人中心 */
    getUser:function(params){
      return axios.get('/users' + this.getParam(params))
    },
     /* 检验token */
    getCheck:function(params){
      return axios.get('/tokens/check')
    },
  
     /* 获取专题详情 */
    getauctionPackId: function (params,id) {
        return axios.get('/auctionPackages/'+ id + this.getParam(params))
    },
    /* 获取微信 */
    getWXinfo: function(params) {
        return axios.get('/tokens/wxinfo' + this.getParam(params));
    },
    getWXbind: function(params) {
        return axios.post('/tokens/wxbind', qs.stringify(params));
    },
     /* 提交微信注册信息  */
    putUserss: function (params) {
        return axios.put('/users' + this.getParam(params))
    },
     /* 绑定微信  */
    postWxbind: function (params) {
        return axios.post('/tokens/wxbind' + this.getParam(params))
    },
      /* 绑定微信  */
    putTokensWxbind: function (params) {
        return axios.put('/tokens/wxbind' + this.getParam(params))
    },
      /* 通用：验证验证码的对错 */
    postValidateImg: function (params) {
        return axios.post('/kaptchas',qs.stringify(params))
    },
     /*  获取微信授权地址  */
    getWxpay:function(params,loginType,platform,jumpRouter,wxscope){
        return axios.get('/tokens/oauth' + this.getParam(params,loginType,platform,jumpRouter,wxscope))
    },
     // 查询个人银行卡
    getBankCard:function(params){
         return axios.get('/bankCard' + this.getParam(params))
    },
      // 查询单个银行卡
    getBankCardid:function(id){
         return axios.get('/bankCard/' + id)
    },
      // 删除银行卡
    deleteBankCardid:function(id){
         return axios.delete('/bankCard/' + id)
    },
     // 修改银行卡
    putBankCardid:function(params){
         return axios.put('/bankCard' + this.getParam(params))
    },
     // 获取提现记录
    getWithdrawflows:function(params){
         return axios.get('/withdrawflows' + this.getParam(params))
    },
    // 获取提现详情
    getWithdrawflowsid:function(id){
         return axios.get('/withdrawflows/' + id)
    },
     // 添加提现
    postWithdrawflowsapply:function(params){
         return axios.post('/withdrawflows/apply',qs.stringify(params))
    },
    // 新添银行卡
    postBankCard:function(params){
         return axios.post('/bankCard',qs.stringify(params))
    },
    // 注册
    postUnbind:function(params){
         return axios.post('/tokens/unbind' + this.getParam(params))
    },
    
    // 短信验证码
    getSms:function(params){
         return axios.get('/sms' + this.getParam(params))
    },
    // 注册
    postUsers:function(params){
         return axios.post('/users' + this.getParam(params))
    },
    // 手机号修改密码
    putPasswordsphone:function(params){
         return axios.put('/passwords/phone' + this.getParam(params))
    },
    // 密码登录
    postPassword:function(params){
         return axios.post('/tokens/password' + this.getParam(params))
    },
    // 退出登录
    deleteTokens:function(){
         return axios.delete('/tokens')
    },
     // 获取用户信息
    getUsersprofile:function(params){
         return axios.get('/users/profile' + this.getParam(params))
    },
     // 修改用户信息
    putUpdate:function(params){
         return axios.put('/update' + this.getParam(params))
    },
     /* 图片  */
    postBase: function (params) {
        return axios.post('/files/base64',qs.stringify(params))
    },
    // 获取字典
    getDictionaries:function(params){
         return axios.get('/dictionaries' + this.getParam(params))
    },
    // 获取单个字典
    getDictionariesid:function(id){
         return axios.get('/dictionaries/' + id)
    },
    // 新增关联
    postUsersfollow:function(params){
         return axios.post('/users/follow' + this.getParam(params))
    },
    // 获取关联列表
    getUsersfollow:function(params){
         return axios.get('/users/follow' + this.getParam(params))
    },
    // 获取写作列表
    getArticleDemandfront:function(params){
         return axios.get('/articleDemand/front/page' + this.getParam(params))
    },
    // 获取写作详情
    getArticleDemandid:function(id){
         return axios.get('/articleDemand/' + id)
    },
    // 获取我的写作列表
    getArticlemypage:function(params){
         return axios.get('/article/myPage' + this.getParam(params))
    },
    // 获取我的写作详情
    getArticleid:function(id,params){
         return axios.get('/article/' + id + this.getParam(params))
    },
     // 记录
    putArticlepvid:function(id,params){
         return axios.put('/article/pv/' + id + this.getParam(params))
    },
     // 新增写作
    postArticle:function(params){
         return axios.post('/article',qs.stringify(params))
    },
     // 申请写作
    postApply:function(params){
         return axios.post('/apply' + this.getParam(params))
    },
     // 修改写作
    putArticle:function(params){
         return axios.put('/article',qs.stringify(params))
    },
    // 获取推广列表
    getChannelDemandmyPage:function(params){
         return axios.get('/channelDemand/myPage' + this.getParam(params))
    },
    // 获取推广详情
    getChannelDemandid:function(id){
         return axios.get('/channelDemand/' + id)
    },
    // 获取我的推广列表
    getChannelsmyPage:function(params){
         return axios.get('/channels/myPage' + this.getParam(params))
    },
    // 获取我的推广详情
    getChannelsId:function(id){
         return axios.get('/channels/' + id)
    },
    // 新增推广
    postChannels:function(params){
         return axios.post('/channels' + this.getParam(params))
    },
    // 点赞
    putArticleid:function(id){
        return axios.put('/article/' + id)
    },
     // 获取我的收入列表
    getWalletflows:function(params){
         return axios.get('/walletflows/query' + this.getParam(params))
    },
     // 获取我的收入总额
    getUserwallets:function(params){
         return axios.get('/userwallets/query' + this.getParam(params))
    },
     // 获取我的消息
    getNotice:function(params){
         return axios.get('/notice' + this.getParam(params))
    },
      // 获取我的未读消息
    getNoticeunread:function(params){
         return axios.get('/notice/unread' + this.getParam(params))
    },
      // 获取我的未读消息
    getNoticenewest:function(params){
         return axios.get('/notice/newest' + this.getParam(params))
    },
    //读取消息
    putNoticeunread:function(params){
         return axios.put('/notice/unread',qs.stringify(params))
    },

       // 获取我的未读数量和最新一条
    getNoticetype:function(params){
         return axios.get('/notice/type' + this.getParam(params))
    },
       // 获取概况图
    getIndexbrokenLine:function(params){
         return axios.get('/index/brokenLine' + this.getParam(params))
    },
      // 获取概况列表
    getIndexlist:function(params){
         return axios.get('/index/list' + this.getParam(params))
    },
      // 获取概况总览
    getIndextitle:function(params){
         return axios.get('/index/title' + this.getParam(params))
    },
     //转发
    putArticleforward:function(id){
         return axios.put('/article/forward/' + id)
    },
    //获取阿里云toen
     getYunToken: function (params) {
        return axios.get('/article/stsToken' + this.getParam(params));
    },
    //文章撤回
     putArticleRepeal: function (params) {
        return axios.put('/article/repeal' + this.getParam(params));
    },



     getParam: function(param){
        let url = '';
        for(let key in param){
            if(param[key] !== null){
                url ? url += '&'+key+'='+param[key] : url += key+'='+param[key]
            }
        }
        return url ? '?'+url : ''
    },
}
export default {commonService}
